package 结业考试;

public class Person {
    private int age;

    public Person() {
    }

    public Person(int age) {
        this.age = age;
    }

    public  void setAge(int age){
        if (age >=0 && age <= 100){
            System.out.println("年龄合法！");
            this.age = age;
        }else {
            System.out.println("年龄不合法！");
        }
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    public String toString() {
        return "Person{age = " + age + "}";
    }
}
